package com.nymph.session;

import com.nymph.session.impl.DefaultSqlSessionFactory;

import java.io.IOException;
import java.io.InputStream;

/**
 * @Description: This is a sample class.
 * @Author: Simon
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(String fileName) {
        InputStream inputStream = SqlSessionFactoryBuilder.class.getClassLoader().getResourceAsStream(fileName);
        return build(inputStream);
    }

    public SqlSessionFactory build(InputStream inputStream) {
        try {
            // 加载配置
            Configuration configuration = new Configuration();
            Configuration.PROPS.load(inputStream);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return new DefaultSqlSessionFactory(new Configuration());
    }
}
